package com.ruix.app.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

import com.ruix.app.R;

/**
 * Created by hadexs on 2017/4/30.
 */

public class ReportPostDialog extends Dialog implements View.OnClickListener{


    private String postid;
//    private int position;
    private ReportPostListener listener;

    public ReportPostDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.dialog_delete_post);
        setCanceledOnTouchOutside(true);
        initEvent();

    }

    private void initEvent(){
       TextView message = (TextView) findViewById(R.id.tv_common_message);
        message.setText("您确定举报该实践？");
        findViewById(R.id.btn_sure).setOnClickListener(this);
        findViewById(R.id.btn_cancel).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_sure:
                dismiss();
                if (listener != null){
                    listener.reportPostPositive(postid);
                }
                break;
            case R.id.btn_cancel:
                dismiss();

                break;
        }
    }

    public void setListener(ReportPostListener listener) {
        this.listener = listener;
    }


    public void show(String postID) {
        this.postid = postID;
//        this.position = commentPosition;
        show();
    }

    public interface ReportPostListener{
        void reportPostPositive(String postID);
    }
}
